<?php 
namespace app\superadmin\controller;
use think\Db;
use think\Controller;
class Comments extends Base{
	public function index(){
		$comments=Db::name('comments c')->join('users u','c.uid=u.uid')->join('videos v','c.vid=v.vid')->where("vstatus='0'")->paginate(10);
		$this->assign('comments',$comments);
		//序号
    $page=request()->param('page');
    $page||($page=1);
    $this->assign('page',$page);
		return $this->fetch();
	}

	//封禁理由1
	public function shield1($cid,$uid){
		// dump($cid);
		// dump($uid);
		$date=['adminid'=>1,
				'uid'=>$uid,
				'itime'=>date('Y-m-d H:i:s'),
				'content'=>'您的的评论包含违法信息'];
				dump($date);
		$res=Db::name('information')->insert($date);
		$res2=Db::name('comments')->where('cid',$cid)->update(['cstatus'=>1]);
		if ($res2) {
			# code...
			$this->redirect('index');
		}else{
			$this->error('封禁失败！');
		}
	}
	//封禁理由2
	public function shield2($cid,$uid){
		// dump($cid);
		// dump($uid);
		$date=['adminid'=>1,
				'uid'=>$uid,
				'itime'=>date('Y-m-d H:i:s'),
				'content'=>'您的评论包含诋毁本网站信息'];
				dump($date);
		$res=Db::name('information')->insert($date);
		$res2=Db::name('comments')->where('cid',$cid)->update(['cstatus'=>1]);
		if ($res2) {
			# code...
			$this->redirect('index');
		}else{
			$this->error('封禁失败！');
		}
	}
	//封禁理由3
	public function shield3($cid,$uid){
		// dump($cid);
		// dump($uid);
		$date=['adminid'=>1,
				'uid'=>$uid,
				'itime'=>date('Y-m-d H:i:s'),
				'content'=>'您的评论包含辱骂他人信息'];
				dump($date);
		$res=Db::name('information')->insert($date);
		$res2=Db::name('comments')->where('cid',$cid)->update(['cstatus'=>1]);
		if ($res2) {
			# code...
			$this->redirect('index');
		}else{
			$this->error('封禁失败！');
		}
	}

	//解除封禁
	public function shield4($cid,$uid){
		// dump($cid);
		// dump($uid);
		$res=Db::name('comments')->where('cid',$cid)->update(['cstatus'=>0]);
		$res2=Db::name('information')->where('uid',$uid)->delete();
		if ($res2) {
			# code...
			$this->redirect('index');
		}else{
			$this->error('解除封禁失败！');
		}
	}
}
